﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace WZN_VoteSys.Models.Database
{
    public partial class WZN_VoteSysContext : DbContext
    {
        public WZN_VoteSysContext()
        {
        }

        public WZN_VoteSysContext(DbContextOptions<WZN_VoteSysContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Award> Awards { get; set; }
        public virtual DbSet<AwardType> AwardTypes { get; set; }
        public virtual DbSet<ClassInfo> ClassInfos { get; set; }
        public virtual DbSet<Enterprise> Enterprises { get; set; }
        public virtual DbSet<Entry> Entrys { get; set; }
        public virtual DbSet<User> Users { get; set; }
        public virtual DbSet<VoteList> VoteLists { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Persist Security Info=False;User ID=sa;Initial Catalog=WZN_VoteSys;Data Source=223.247.140.116,57587;Password=Yixuhongxi1");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<Award>(entity =>
            {
                entity.ToTable("Award");

                entity.Property(e => e.AwardTime)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasDefaultValueSql("(getdate())");

                entity.Property(e => e.AwardTypeId).HasColumnName("AwardTypeID");

                entity.Property(e => e.EnterpriseId).HasColumnName("enterpriseID");

                entity.Property(e => e.UpdateImg1).HasMaxLength(500);

                entity.Property(e => e.UpdateImg2).HasMaxLength(500);

                entity.Property(e => e.UpdateImg3).HasMaxLength(500);

                entity.Property(e => e.UpdateImg4).HasMaxLength(500);

                entity.Property(e => e.UpdateImg5).HasMaxLength(500);
            });

            modelBuilder.Entity<AwardType>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("AwardType");

                entity.Property(e => e.AwardTypeId).HasColumnName("AwardTypeID");

                entity.Property(e => e.AwardtypeName)
                    .IsRequired()
                    .HasMaxLength(50);
            });

            modelBuilder.Entity<ClassInfo>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("ClassInfo");

                entity.Property(e => e.ClassName)
                    .IsRequired()
                    .HasMaxLength(50);
            });

            modelBuilder.Entity<Enterprise>(entity =>
            {
                entity.ToTable("enterprise");

                entity.Property(e => e.EnterpriseId).HasColumnName("enterpriseID");

                entity.Property(e => e.EnterpriseInfo)
                    .IsRequired()
                    .HasMaxLength(500)
                    .HasColumnName("enterpriseInfo");

                entity.Property(e => e.Enterprisename)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("enterprisename");
            });

            modelBuilder.Entity<Entry>(entity =>
            {
                entity.ToTable("entrys");

                entity.Property(e => e.EntryId).HasColumnName("entryID");

                entity.Property(e => e.Email)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.EnterpriseId).HasColumnName("enterpriseID");

                entity.Property(e => e.Statues).HasColumnName("statues");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.ToTable("users");

                entity.Property(e => e.Userid).HasColumnName("userid");

                entity.Property(e => e.Email)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.Password)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.Phone)
                    .HasMaxLength(50)
                    .HasColumnName("phone");

                entity.Property(e => e.Sex)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("sex")
                    .HasDefaultValueSql("(N'男')");
            });

            modelBuilder.Entity<VoteList>(entity =>
            {
                entity.HasKey(e => e.Voteid);

                entity.ToTable("voteList");

                entity.Property(e => e.Voteid).HasColumnName("voteid");

                entity.Property(e => e.Email)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.EntyId).HasColumnName("entyID");

                entity.Property(e => e.VoteTime)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("voteTime")
                    .HasDefaultValueSql("(getdate())");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
